package test.pcs;

import com.payment.lc.pcs.client.wrap.bo.ProductionChannelAttributes;
import com.payment.lc.pcs.client.wrap.bo.ProductionTimeAttributes;
import com.payment.lc.pcs.client.wrap.model.ZiGuanTime;
import com.payment.lc.pcs.client.wrap.service.ProductionWrapService;
import com.payment.lc.pcs.common.enums.BizType;
import com.payment.lc.pcs.common.enums.DisplayType;
import com.payment.lc.pcs.common.enums.GroupType;
import com.payment.lc.pcs.common.enums.MiProductCategory;
import com.payment.lc.pcs.service.api.DynamicDataService;
import com.payment.lc.pcs.service.api.ProductionService;
import com.payment.lc.pcs.service.api.fund.JMFundService;
import com.payment.lc.pcs.service.api.modify.InterestRateService;
import com.payment.lc.pcs.service.api.modify.PcsChannelService;
import com.payment.lc.pcs.service.bo.ProductionTime;
import com.payment.lc.pcs.service.domain.*;
import com.payment.lc.pcs.service.request.InterestRateImportRequest;
import com.payment.lc.pcs.service.response.BaseResponse;
import com.sun.crypto.provider.HmacPKCS12PBESHA1;
import com.sun.scenario.effect.impl.prism.PrDrawable;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import test.BaseTest;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created on 2016/8/8.
 */
public class Demo3PcsRevisionTest3 extends BaseTest {


    @Autowired
    JMFundService jmFundService;

    @Autowired
    ProductionWrapService productionWrapService;

    @Autowired
    InterestRateService interestRateService;

    @Autowired
    DynamicDataService dynamicDataService;

    @Autowired
    PcsChannelService pcsChannelService;

    static String huoqi1 = "000009";
    static String huoqi2 = "JM000709";
    static String dingqiP1 = "FP16006";
    static String dingqiP2 = "FP16001";
    static String huoqiP1 = "MP0006";
    static String dingqi1 = "FI16022";
    static String dingqi2 = "FI16003";
    static String jijin1 = "JM110022";
    static String huangjin = "000217";
    static String ziguan = "SU0365";
    static String ziguan1 = "SF3501";
    static String yuegujiao = "17120007";
//    static String prodCode = "JM000509";
//    static String prodCode = "ZG0001";

    static List<String> prodCodes = new ArrayList<>();

    {
        prodCodes.add(huoqi1);
        prodCodes.add(huoqi2);
        prodCodes.add(dingqiP1);
        prodCodes.add(dingqiP2);
        prodCodes.add(huoqiP1);
        prodCodes.add(dingqi1);
        prodCodes.add(dingqi2);
        prodCodes.add(jijin1);
        prodCodes.add(huangjin);
        prodCodes.add(ziguan);
        prodCodes.add(ziguan1);
        prodCodes.add(yuegujiao);
    }

    @Autowired
    @Qualifier("productionService")
    ProductionService productionService;

    @Autowired
    @Qualifier("productionServiceLocal")
    ProductionService productionServiceLocal;

    @Test
    public void test() {
        test1();
    }

    static String path = "d:/WebStormWorkspace3/mifi_pcs_v2/mock/";
    String prodCode = prodCodes.get(11);



    void test6() {
//        String productionCode = prodCode;
        String productionCode = yuegujiao;

        Object obj = productionServiceLocal.getDisplayUpOrderedProductions(GroupType.MobileFrontPageGroup,"DingqiListMore");
        display(obj);
        writeTo(obj, path + "tmp.json");

        Object obj1 = productionService.getDisplayUpOrderedProductions(GroupType.MobileFrontPageGroup,"DingqiListMore");
        display(obj);
        writeTo(obj1, path + "tmp1.json");

    }

    void test5() {
        for (int i = 0; i < prodCodes.size(); i++) {
            String productionCode = prodCodes.get(i);
            Object obj = productionServiceLocal.getInsuranceV2(productionCode);
            String str = getJSONString(obj);
            display(str);
            writeTo(obj, path + "tmp" + i + "_0.json");

            Object obj1 = productionService.getInsuranceV2(productionCode);
            String str1 = getJSONString(obj1);
            display(str1);
            writeTo(str1, path + "tmp" + i + "_1.json");

            System.out.println(i + ":" + str.equals(str1));
        }
    }

    void test4() {
//        String productionCode = prodCode;
        String productionCode = yuegujiao;

        Object obj = productionServiceLocal.getDynamicInfoList(productionCode);
        display(obj);
        writeTo(obj, path + "tmp.json");

        Object obj1 = productionService.getDynamicInfoList(productionCode);
        display(obj);
        writeTo(obj1, path + "tmp1.json");

    }

    void test3() {
//        String productionCode = prodCode;
        String productionCode = dingqiP1;

        Object obj = productionServiceLocal.getInsuranceV2(productionCode);
        display(obj);
        writeTo(obj, path + "tmp.json");

        Object obj1 = productionService.getInsuranceV2(productionCode);
        display(obj);
        writeTo(obj1, path + "tmp1.json");

    }

    void test2() {
        ArrayList<MiProductCategory> categories = new ArrayList<>();
        categories.add(MiProductCategory.Huoqi);
        categories.add(MiProductCategory.DingqiP);

        ArrayList<DisplayType> displayTypes = new ArrayList<>();
        displayTypes.add(DisplayType.Up);

        Object obj = productionServiceLocal.getProductionsByCategoryDisplayType(categories, displayTypes);
        display(obj);
        writeTo(obj, path + "tmp.json");

        Object obj1 = productionService.getProductionsByCategoryDisplayType(categories, displayTypes);
        writeTo(obj1, path + "tmp1.json");
    }

    void test1() {
//        String productionCode = prodCode;
        String productionCode = "FI16002";

        Object obj = productionServiceLocal.getProduction(productionCode);
        display(obj);
        writeTo(obj, path + "tmp.json");

        Object obj1 = productionService.getProduction(productionCode);
        writeTo(obj1, path + "tmp1.json");
        display(((Production) obj1).getCurrentDynamicInfo());
    }

    void test400() {
        Object obj = dynamicDataService.getProductionSellInfo("FI16017");
        display(obj);
    }
}